<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<%@ include file="/commons/commonList.jsp" %>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>保证金补退</title>
<link href="${ctx}/css/grid.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="${ctx}/scripts/global.js"></script>
<script type="text/javascript" src="${ctx}/scripts/div/common.js"></script>
<script type="text/javascript" src="${ctx}/scripts/public.js"></script>
<script type="text/javascript" src="${ctx}/scripts/common/prototype.js"></script>
<script type="text/javascript" src="${ctx}/scripts/common.js"></script>
<script type="text/javascript" src="${ctx}/scripts/ajaxException.js"></script>

<script type="text/javascript">

	var ACTION_URL = "${ctx}/renovation_depositAccountingAction.do?";

	var inspectionRequistionId = "";
	var licenceId = "";
	var depositAccountingId="";

	function resize(){
		parent.window.document.all('depositAccountingListIfm').style.height=document.body.scrollHeight;
	}

	function init(){  //初始化
	 	parent.cur_p='${ec_p}';
		resize();
	}

	function  setInsReqId(licId,insId,depAccId){  //设置申请验收Id
		this.licenceId = licId;
		this.inspectionRequistionId= insId;
		this.depositAccountingId=depAccId;
	}

	function checkDeppositAccounting(){ //检查是否可以进行保证金核算
		var url ="${ctx}/renovation_depositAccountingAction.do?method=checkDeppositAccounting";
		new Ajax.Request(url,
			         { method:'post',
					   parameters:{licenceId:licenceId},
					   onComplete:openDeppositAccounting
					 });
	}
	function openDeppositAccounting(response){ //打开保证金核算
		var flag = response.responseText;
		if(flag == "false"){
			Alert("只有新建或未通过的数据才能进行补退核算!");
			return ;
		}

		var url = ACTION_URL+"method=navigateCountDeposit&licenceId="+licenceId;
   		top.windowOpen(url, "countDeposit", "保证金补退核算", 380, 800,true,"countDepositIfm");

	}

	function checkSubmit(){  //检查是否可以进行提交
		var url =ACTION_URL+"method=checkSubmit";
		new Ajax.Request(url,
			         { method:'post',
					   parameters:{licenceId:licenceId},
					   onComplete:openSubmit
					 });
	}

	function openSubmit(response){ //提交确认

		var flag = response.responseText;
		if (flag == "false"){
			Alert("只有新建状态的数据才可能提交！");
			return ;
		}
		AskConfirm("确定要提交这条记录吗?","depositAccountingListIfm","editSubmit");
	}

	function editSubmit(depAccId){

		if (depAccId == null){
			depAccId="";
		}
		var params ="";
		var url =ACTION_URL+"method=submitInfo&licenceId="+licenceId+"&depositAccountingId="+depAccId;

		sendAjaxRequest(url,params,function(response){
				ajaxSubmitException(response.responseText);
				findFrame('main').reflesh();  //刷新主页面列表
		});
	}

	function checkRenovateApproval(){//检查审批
		var url =ACTION_URL+"method=checkRenovateApproval";
		new Ajax.Request(url,
			         { method:'post',
					   parameters:{depositAccountingId:depositAccountingId},
					   onComplete:openRenovateApproval
					 });
	}
	function openRenovateApproval(response){ //打开审批主页面
		var msg = response.responseText;
		if (msg != "true"){
			Alert(msg);
			return ;
		}

		var url = ACTION_URL+"method=navigateRenovateApprovalMain&inspectionRequistionId="+inspectionRequistionId+"&depositAccountingId="+depositAccountingId+"&licenceId="+licenceId;
   		top.windowOpen(url, "renovateApprovalMain", "保证金补退审批", 380, 900,true,"renovateApprovalMainIfm");
	}

	function openDetailPage(licenceId,inspectionRequistionId){//打开详细主页面

		var url = ACTION_URL+"method=navigateDetailMain&inspectionRequisitionId="+inspectionRequistionId+"&licenceId="+licenceId+"&depositAccountingId="+depositAccountingId;
   		top.windowOpen(url, "detailPage", "详细资料", 380,900,true,"detailPageIfm");
	}

	function openSubmitPage(inspectionReqnId){ //打开提交页面

		var url = ACTION_URL+"method=navigateSubmitPage&inspectionRequistionId="+inspectionReqnId;
   		top.windowOpen(url, "submitPage", "提交", 200,500,true,"submitPageIfm");
	}

</script>


</head>


<body  onload="init();">

<div id="ceTable_Bottom">
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
	   <tr class="grid2">
	       <td colspan="8" class="chareg_hj">金额合计：</td>
	       <td align="right" class="chareg_hj"><span class="font_red">${countSum }</span>&nbsp;元&nbsp;</td>
	       <td  class="chareg_hj">&nbsp;</td>
	   </tr>
	</table>
 </div>

	<div style="overflow:auto; " >

	<ec:ceTable items="depositList"
				autoIncludeParameters="true"
				var="item"
				action="${ctx}/renovation_depositAccountingAction.do?method=queryDepositAccounting"
				rowsDisplayed="15"
				width="100%"
				view="pmsview"
				sortable="false"
				styleClass="gridData"
			>
		<ec:ceRow styleClass="grid" ondblclick="openDetailPage('${item.licenceId}','${item.inspectionRequistionId}','${item.depositAccountingId }');" onclick="setInsReqId('${item.licenceId}','${item.inspectionRequistionId}','${item.depositAccountingId }');"  onContextMenu="return ShowContextMenu(event,'quick_rightmenu');">
			<ec:ceColumn width="14%"  property="licenceNumber" headerCell="pmsHeadrCell"  title="装修许可证号" />
			<ec:ceColumn width="11%"  property="houseNumber" headerCell="pmsHeadrCell"  title="房 号" sortable="true" />
			<ec:ceColumn width="11%"  property="clientNames" headerCell="pmsHeadrCell"  title="业主姓名"/>
			<ec:ceColumn width="12%"  property="returnTerm" headerCell="pmsHeadrCell" title="退还期限" sortable="true" cell="date" parse="yyyy-MM-dd"/>
			<ec:ceColumn width="12%"  property="accountingDate" headerCell="pmsHeadrCell" title="核算时间" sortable="true"  cell="date" parse="yyyy-MM-dd"/>
			<ec:ceColumn width="10%"  property="accountingMan" headerCell="pmsHeadrCell"  title="核算人"></ec:ceColumn>
			<ec:ceColumn width="10%"  property="approvalStateView" headerCell="pmsHeadrCell" title="审批状态" />
			<ec:ceColumn width="10%"  property="returnSum" headerCell="pmsHeadrCell" title="退还金额" />
			<ec:ceColumn width="10%"  property="feeStateView" headerCell="pmsHeadrCell" title="费用状态" />
		</ec:ceRow>
	</ec:ceTable>

	</div>



<div id="quick_rightmenu" style="display:none;" oncontextmenu="return false" class="quick_menu2" onMouseOver="showmy2menu('quick_rightmenu')"  onMouseOut="hidden2menu('quick_rightmenu')" >
  <table width="100%" border="0" cellpadding="0" cellspacing="0" class="grid_quickMenu_bg">
    <tr>
      <td>
      <table width="100%" border="0" cellpadding="2" cellspacing="0">
        <pms:AuthTag authName="renovation_depositAccountingAction.do?method=depositAndAmercement">
        <tr>
          <td class="quickMenu_toolbarico"><a href="#"  onClick="checkDeppositAccounting();"onFocus="this.blur()"><img src="${ctx}/images/ico_zx_thjine.gif" alt="退还金额核算" width="16" height="16" border="0" align="absbottom" /> 退还金额核算</a></td>
        </tr>
        </pms:AuthTag>
        <pms:AuthTag authName="renovation_depositAccountingAction.do?method=submitInfo">
		<tr>
          <td class="quickMenu_toolbarico"><a href="#" onClick="checkSubmit();" onFocus="this.blur()"><img src="${ctx}/images/ico_submit.gif" alt="提 交" width="16" height="16" border="0" align="absbottom" /> 提 交</a></td>
        </tr>
        </pms:AuthTag>
        <pms:AuthTag authName="renovation_depositAccountingAction.do?method=addRenovateApproval">
         <tr>
          <td class="quickMenu_toolbarico"><a href="#"  onClick="checkRenovateApproval();" onFocus="this.blur()"><img src="${ctx}/images/ico_shenpi_zong1.gif" border="0" align="absbottom" />&nbsp;审 批</a></td>
        </tr>
        </pms:AuthTag>
	  </table>
	</td>
    </tr>
  </table>
  <script type="text/javascript">

	var div1=document.getElementById('quick_rightmenu');
	if(div1.getElementsByTagName("tr").length==1){
	div1.innerHTML="";
	}
</script>
</div>

</body>
</html>
